﻿<Window x:Class="WbfsSync.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WbfsSync.Controls"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        x:Name="mainWindow" Title="" Height="516" Width="809">

    <TextOptions.TextFormattingMode>
        Display
    </TextOptions.TextFormattingMode>
    
    <Window.Resources>

        <!-- CollectionView -->
        
        <CollectionViewSource x:Key="collectionViewSource"
                              Source="{Binding BrowserCollection, ElementName=mainWindow}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Group"/>
            </CollectionViewSource.GroupDescriptions>
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="GroupIdx"/>
            </CollectionViewSource.SortDescriptions>
            
        </CollectionViewSource>
        
        <!-- Tile Template -->
        
        <DataTemplate x:Key="tileItemTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                
                <Rectangle x:Name="iconFrame" StrokeThickness="1"
                           Stroke="#dedede" RadiusX="1" RadiusY="1"
                           Visibility="Hidden" Grid.Column="0"
                           Width="{Binding FrameSize}"
                           Height="{Binding FrameSize}"
                           Margin="4,0,6,0"/>
                
                <Image x:Name="iconImage"
                       Grid.Column="0" Source="{Binding Icon}"
                       Height="{Binding IconWidth}"
                       Width="{Binding IconHeight}"
                       MaxHeight="{Binding FrameSize}"
                       MaxWidth="{Binding FrameSize}"
                       VerticalAlignment="Center"
                       Margin="4,0,6,0" Stretch="Uniform" 
                       RenderOptions.BitmapScalingMode="HighQuality"/>

                <Image x:Name="shortcutImage"
                       Grid.Column="0"
                       Height="{Binding IconWidth}"
                       Width="{Binding IconHeight}"
                       MaxHeight="{Binding FrameSize}"
                       MaxWidth="{Binding FrameSize}"
                       VerticalAlignment="Center"
                       Margin="4,0,6,0" Stretch="Uniform" 
                       RenderOptions.BitmapScalingMode="HighQuality"/>

                <StackPanel Grid.Column="1" Orientation="Vertical" 
                            VerticalAlignment="Center">
                    
                    <TextBlock Text="{Binding Name}" MaxHeight="32px" TextWrapping="Wrap"
                               Foreground="Black" TextTrimming="CharacterEllipsis" Margin="0,2,4,2" />

                    <Grid Margin="0,0,4,2">
                        
                        <TextBlock Foreground="#6d6d6d">
                            <Run Text="{Binding Type}" x:Name="typeText"/>
                            <Run Text="{Binding Region}"/>
                            <LineBreak/>
                            <Run Text="{Binding Size}"/>
                        </TextBlock>
                        
                        <ProgressBar x:Name="sizePBar" Margin="0,0,0,0"
                                     Background="White" Foreground="#FF009CFF"
                                     Style="{StaticResource sizeBarStyle}"
                                     VerticalAlignment="Top"
                                     Visibility="Hidden" Height="13"/>
                        
                    </Grid>
                </StackPanel>
                
            </Grid>
            
            <DataTemplate.Triggers>
                
                <DataTrigger Binding="{Binding IsGame}" Value="True">
                    <Setter Property="Image.Effect" TargetName="iconImage">
                        <Setter.Value>
                            <DropShadowEffect Opacity="0.5" BlurRadius="4" 
                                              Color="Black" ShadowDepth="2"/>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>

                <DataTrigger Binding="{Binding IsGame}" Value="True">
                    <Setter Property="Run.Text" TargetName="typeText" Value="{Binding Code}" />    
                </DataTrigger>

                <DataTrigger Binding="{Binding IsSmallIcon}" Value="True">
                    <Setter Property="Rectangle.Visibility" TargetName="iconFrame" Value="Visible"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding IsShortcut}" Value="True">
                    <Setter Property="Image.Source" TargetName="shortcutImage" Value="{Binding ShortcutOverlay}"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding IsDriveAndReady}" Value="True">
                    <Setter Property="ProgressBar.Visibility" TargetName="sizePBar" Value="Visible"/>
                    <Setter Property="ProgressBar.Value" TargetName="sizePBar" Value="{Binding DriveUsed}"/>
                    <Setter Property="ProgressBar.Maximum" TargetName="sizePBar" Value="{Binding DriveSize}"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding IsDriveAndLowSpace}" Value="True">
                    <Setter Property="ProgressBar.Foreground" TargetName="sizePBar" Value="#FFFF0000"/>
                </DataTrigger>

            </DataTemplate.Triggers>
            
        </DataTemplate>

        <!-- Small Template -->

        <DataTemplate x:Key="smallItemTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Image x:Name="iconImage"
                       Grid.Column="0" Source="{Binding Icon}"
                       Height="{Binding IconWidth}"
                       Width="{Binding IconHeight}"
                       MaxHeight="{Binding FrameSize}"
                       MaxWidth="{Binding FrameSize}"
                       VerticalAlignment="Center"
                       Margin="4,1,6,0" Stretch="Uniform" 
                       RenderOptions.BitmapScalingMode="HighQuality"
                       SnapsToDevicePixels="True"/>

                <Image x:Name="shortcutImage"
                       Grid.Column="0"
                       Height="{Binding IconWidth}"
                       Width="{Binding IconHeight}"
                       MaxHeight="{Binding FrameSize}"
                       MaxWidth="{Binding FrameSize}"
                       VerticalAlignment="Center"
                       Margin="4,1,6,0" Stretch="Uniform" 
                       RenderOptions.BitmapScalingMode="HighQuality"
                       SnapsToDevicePixels="True"/>

                <TextBlock Text="{Binding Name}" MaxHeight="32px" TextWrapping="Wrap"
                           Foreground="Black" TextTrimming="CharacterEllipsis" Margin="0,2,4,2"
                           Grid.Column="1"/>
            </Grid>

            <DataTemplate.Triggers>

                <DataTrigger Binding="{Binding IsShortcut}" Value="True">
                    <Setter Property="Image.Source" TargetName="shortcutImage" Value="{Binding ShortcutOverlay}"/>
                </DataTrigger>

            </DataTemplate.Triggers>
        </DataTemplate>
        
        <!-- Large Template -->

        <DataTemplate x:Key="largeItemTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Rectangle x:Name="iconFrame" StrokeThickness="1"
                           Stroke="#dedede" RadiusX="1" RadiusY="1"
                           HorizontalAlignment="Center"
                           Visibility="Hidden" Grid.Row="0"
                           Width="{Binding FrameSize}"
                           Height="{Binding FrameSize}"
                           Margin="0,0,0,0"/>

                <Image x:Name="iconImage"
                       Grid.Row="0" Source="{Binding Icon}"
                       Height="{Binding IconWidth}"
                       Width="{Binding IconHeight}"
                       MaxHeight="{Binding FrameSize}"
                       MaxWidth="{Binding FrameSize}"
                       HorizontalAlignment="Center"
                       Margin="0,1,0,0" Stretch="Uniform" 
                       RenderOptions.BitmapScalingMode="HighQuality"
                       SnapsToDevicePixels="True"/>

                <Image x:Name="shortcutImage"
                       Grid.Row="0"
                       Height="{Binding IconWidth}"
                       Width="{Binding IconHeight}"
                       MaxHeight="{Binding FrameSize}"
                       MaxWidth="{Binding FrameSize}"
                       HorizontalAlignment="Center"
                       Margin="0,1,0,0" Stretch="Uniform" 
                       RenderOptions.BitmapScalingMode="HighQuality"
                       SnapsToDevicePixels="True"/>

                <TextBlock Grid.Row="1" Text="{Binding Name}" 
                           MaxHeight="32px" TextWrapping="Wrap"
                           Foreground="Black" Margin="0,2,4,2"
                           TextTrimming="CharacterEllipsis"
                           HorizontalAlignment="Center"
                           TextAlignment="Center"/>

            </Grid>

            <DataTemplate.Triggers>

                <DataTrigger Binding="{Binding IsGame}" Value="True">
                    <Setter Property="Image.Effect" TargetName="iconImage">
                        <Setter.Value>
                            <DropShadowEffect Opacity="0.5" BlurRadius="4" 
                                              Color="Black" ShadowDepth="2"/>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>

                <DataTrigger Binding="{Binding IsSmallIcon}" Value="True">
                    <Setter Property="Rectangle.Visibility" TargetName="iconFrame" Value="Visible"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding IsShortcut}" Value="True">
                    <Setter Property="Image.Source" TargetName="shortcutImage" Value="{Binding ShortcutOverlay}"/>
                </DataTrigger>

            </DataTemplate.Triggers>
        </DataTemplate>

        <!-- Detail View -->

        <Style x:Key="headerContainerStyle" TargetType="{x:Type GridViewColumnHeader}">
            <Setter Property="Height" Value="25"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                        <Border x:Name="OuterBorder" BorderThickness="0,1,1,1" Background="Transparent">
                            <Border x:Name="InnerBorder" BorderThickness="1" Margin="1,0,0,0">
                                <TextBlock Text="{TemplateBinding Content}" Padding="5" Width="{TemplateBinding Width}" 
                                           TextAlignment="Left" VerticalAlignment="Center" Foreground="#4c607a"/>
                            </Border>
                            
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Offset="0" Color="#ffdfeaf7"/>
                                    <GradientStop Offset="1" Color="#00dfeaf7"/>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            
                        </Border>
                        
                        <ControlTemplate.Triggers>
                            
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#ffdfeaf7"/>
                                <Setter Property="Border.BorderBrush" TargetName="InnerBorder" Value="White"/>
                                <Setter Property="Border.BorderThickness" TargetName="OuterBorder" Value="1"/>
                                <Setter Property="Border.BorderThickness" TargetName="InnerBorder" Value="1"/>
                                <Setter Property="Border.Margin" TargetName="InnerBorder" Value="0"/>
                                <Setter Property="Border.Background" TargetName="OuterBorder" Value="#eff4fa"/>
                            </Trigger>
                            
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#ffc0cbd9"/>
                                <Setter Property="Border.BorderBrush" TargetName="InnerBorder" Value="Transparent"/>
                                <Setter Property="Border.Background" TargetName="OuterBorder">
                                    <Setter.Value>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                            <GradientStop Offset="0" Color="#ffd7dee7"/>
                                            <GradientStop Offset="0.08" Color="#fff6f7f8"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            
                        </ControlTemplate.Triggers>
                        
                    </ControlTemplate>
                </Setter.Value>                
            </Setter> 
        </Style>

        <GridView x:Key="detailModeView" ColumnHeaderContainerStyle="{StaticResource headerContainerStyle}">
            <GridViewColumn Width="140" Header="Name">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            
                            <Image Margin="4,2,4,2" Source="{Binding Icon}" 
                                   Stretch="Fill"  Grid.Column="0"
                                   Width="16" Height="16"/>

                            <Image x:Name="shortcutImage"
                                   Margin="4,2,4,2"
                                   Grid.Column="0"
                                   Height="16" Width="16"
                                   Stretch="Fill"/>

                            <TextBlock Margin="0,2,4,2" TextTrimming="CharacterEllipsis" 
                                       Text="{Binding Name}" TextWrapping="NoWrap"
                                       Foreground="Black" Grid.Column="1"/>
                        </Grid>
                        
                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding IsShortcut}" Value="True">
                                <Setter Property="Image.Source" TargetName="shortcutImage" Value="{Binding ShortcutOverlay}"/>
                            </DataTrigger>
                        </DataTemplate.Triggers>
                        
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            
            <GridViewColumn Width="72" Header="Code">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Margin="0" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Text="{Binding Code}" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            
            <GridViewColumn Width="72" Header="Region">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Margin="0" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Text="{Binding Region}" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            
            <GridViewColumn Width="128" Header="Type">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Margin="0" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Text="{Binding Type}" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            
            <GridViewColumn Width="150" Header="Size">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Margin="0" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Text="{Binding Size}" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            
        </GridView>
        
        <!-- Tile View -->

        <local:PlainView x:Key="tileModeView" ItemTemplate="{StaticResource tileItemTemplate}"/>

        <!-- Small View -->

        <local:PlainView x:Key="smallModeView" ItemTemplate="{StaticResource smallItemTemplate}"/>

        <!-- Large View -->

        <local:PlainView x:Key="largeModeView" ItemTemplate="{StaticResource largeItemTemplate}"/>

        <!-- Expander style -->

        <PathGeometry x:Key="TreeArrow" Figures="M0,0 L0,6 L6,0 z"/>

        <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Padding="{TemplateBinding Padding}">
                            <Grid Background="Transparent" SnapsToDevicePixels="False">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="6"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Path x:Name="ExpandPath" Data="{StaticResource TreeArrow}" Fill="Transparent" Stroke="#FF989898"
                                      VerticalAlignment="Center" Height="6" Width="6" SnapsToDevicePixels="True">
                                    <Path.RenderTransform>
                                        <RotateTransform Angle="135" CenterY="3" CenterX="3"/>
                                    </Path.RenderTransform>
                                </Path>
                                <ContentPresenter Grid.Column="1" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="RenderTransform" TargetName="ExpandPath">
                                    <Setter.Value>
                                        <RotateTransform Angle="180" CenterY="3" CenterX="3"/>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="Fill" TargetName="ExpandPath" Value="#FF595959"/>
                                <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF262626"/>
                            </Trigger>
                            
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF1BBBFA"/>
                                <Setter Property="Fill" TargetName="ExpandPath" Value="Transparent"/>
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Padding="{TemplateBinding Padding}">
                            <Grid Background="Transparent" SnapsToDevicePixels="False">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="19"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Grid>
                                    <Grid.LayoutTransform>
                                        <TransformGroup>
                                            <TransformGroup.Children>
                                                <TransformCollection>
                                                    <RotateTransform Angle="-90"/>
                                                </TransformCollection>
                                            </TransformGroup.Children>
                                        </TransformGroup>
                                    </Grid.LayoutTransform>
                                    <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="19" Stroke="DarkGray" VerticalAlignment="Center" Width="19"/>
                                    <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="2" VerticalAlignment="Center"/>
                                </Grid>
                                <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="true">
                                <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                                <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Padding="{TemplateBinding Padding}">
                            <Grid Background="Transparent" SnapsToDevicePixels="False">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="19"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid>
                                    <Grid.LayoutTransform>
                                        <TransformGroup>
                                            <TransformGroup.Children>
                                                <TransformCollection>
                                                    <RotateTransform Angle="180"/>
                                                </TransformCollection>
                                            </TransformGroup.Children>
                                        </TransformGroup>
                                    </Grid.LayoutTransform>
                                    <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="19" Stroke="DarkGray" VerticalAlignment="Center" Width="19"/>
                                    <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="2" VerticalAlignment="Center"/>
                                </Grid>
                                <ContentPresenter Grid.Column="1" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="true">
                                <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                                <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style x:Key="ExpanderLeftHeaderStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Padding="{TemplateBinding Padding}">
                            <Grid Background="Transparent" SnapsToDevicePixels="False">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="19"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Grid>
                                    <Grid.LayoutTransform>
                                        <TransformGroup>
                                            <TransformGroup.Children>
                                                <TransformCollection>
                                                    <RotateTransform Angle="90"/>
                                                </TransformCollection>
                                            </TransformGroup.Children>
                                        </TransformGroup>
                                    </Grid.LayoutTransform>
                                    <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="19" Stroke="DarkGray" VerticalAlignment="Center" Width="19"/>
                                    <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="2" VerticalAlignment="Center"/>
                                </Grid>
                                <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="true">
                                <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                                <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style x:Key="ExpanderHeaderFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border>
                            <Rectangle Margin="0" SnapsToDevicePixels="true" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style x:Key="groupExpanderStyle" TargetType="{x:Type Expander}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Expander}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3" SnapsToDevicePixels="true">
                            <DockPanel>
                                <ToggleButton x:Name="HeaderSite" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Content="{TemplateBinding Header}" DockPanel.Dock="Top" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" MinWidth="0" MinHeight="0" Padding="{TemplateBinding Padding}" Style="{StaticResource ExpanderDownHeaderStyle}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <ContentPresenter x:Name="ExpandSite" DockPanel.Dock="Bottom" Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </DockPanel>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="true">
                                <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                            </Trigger>
                            <Trigger Property="ExpandDirection" Value="Right">
                                <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
                                <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
                                <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderRightHeaderStyle}"/>
                            </Trigger>
                            <Trigger Property="ExpandDirection" Value="Up">
                                <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
                                <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
                                <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderUpHeaderStyle}"/>
                            </Trigger>
                            <Trigger Property="ExpandDirection" Value="Left">
                                <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/>
                                <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/>
                                <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderLeftHeaderStyle}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>

    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Copy" CanExecute="CanCopy" Executed="Copy"/>
        <CommandBinding Command="ApplicationCommands.Cut" CanExecute="CanCut" Executed="Cut"/>
        <CommandBinding Command="ApplicationCommands.Paste" CanExecute="CanPaste" Executed="Paste"/>
        
        <CommandBinding Command="EditingCommands.EnterParagraphBreak" CanExecute="CanOpen" Executed="Open" />
        <CommandBinding Command="EditingCommands.Backspace" CanExecute="CanBack" Executed="Back" />
        <CommandBinding Command="EditingCommands.Delete" CanExecute="CanDelete" Executed="Delete" />
        <CommandBinding Command="EditingCommands.CorrectSpellingError" CanExecute="CanRename" Executed="Rename" />
    </Window.CommandBindings>
    
    <Window.InputBindings>
        <KeyBinding Command="EditingCommands.CorrectSpellingError" Key="F2"/>
        <KeyBinding Command="EditingCommands.EnterParagraphBreak" Key="Enter"/>
        <KeyBinding Command="EditingCommands.Delete" Key="Delete"/>
    </Window.InputBindings>

    <Grid>
        
        <!-- Navigation Bar -->

        <Grid Name="navigationGrid" Height="33" VerticalAlignment="Top">
            <Image Source="Icons/Navigation/navbar_frame.png" HorizontalAlignment="Left" Width="50" Stretch="None" Margin="2,0,0,0" />
            <local:ImageButton x:Name="navigationHistory" ImageSource="Icons/Navigation/navbar_dropdown.PNG" Width="19" Height="29" Margin="52,2,0,0" HorizontalAlignment="Left" IsEnabled="False" VerticalAlignment="Top" />
            <local:ImageButton x:Name="navigationBackward" ImageSource="./Icons/Navigation/navbar_backward.png" Width="27" Height="27" Margin="2,3,0,0" HorizontalAlignment="Left" IsEnabled="False" VerticalAlignment="Top"/>
            <local:ImageButton x:Name="navigationForward" ImageSource="./Icons/Navigation/navbar_forward.png" Width="27" Height="27" Margin="30,3,0,0" HorizontalAlignment="Left" IsEnabled="False" VerticalAlignment="Top"/>

            <local:PathBox x:Name="addressBar" VerticalAlignment="Top" Height="24" Margin="70,4,247,0" />
            <local:SearchBox x:Name="searchBar" Margin="0,4,1,5" HorizontalAlignment="Right" Width="242" />

        </Grid>

        <!-- Menu Bar -->
        
        <Grid Name="menuGrid" Margin="0,35,0,0" VerticalAlignment="Top" Height="31">
            <Grid.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Offset="0" Color="#fffdfeff" />
                    <GradientStop Offset="0.48" Color="#ffe6f0fa" />
                    <GradientStop Offset="0.48" Color="#ffdce6f4" />
                    <GradientStop Offset="0.90" Color="#ffdde9f7" />
                    <GradientStop Offset="0.93" Color="#ffe4effb" />
                    <GradientStop Offset="1" Color="#ffa0afc3" />
                </LinearGradientBrush>
            </Grid.Background>
            
            <StackPanel Orientation="Horizontal" Margin="4,0,419,0">
                
                <local:MenuButton Height="24" Width="Auto" Margin="0,3,0,4"
                                  Command="ApplicationCommands.Cut">
                    <TextBlock Margin="9,0,9,0" Text="Cut"/>
                </local:MenuButton>

                <local:MenuButton Height="24" Width="Auto" Margin="0,3,0,4"
                                  Command="ApplicationCommands.Copy">
                    <TextBlock Margin="9,0,9,0" Text="Copy"/>
                </local:MenuButton>

                <local:MenuButton Height="24" Width="Auto" Margin="0,3,0,4"
                                  Command="ApplicationCommands.Paste">
                    <TextBlock Margin="9,0,9,0" Text="Paste"/>
                </local:MenuButton>

                <local:MenuButton x:Name="menuNewLibrary" Margin="0,3,0,4" 
                                  Height="24" Width="Auto">
                    <TextBlock Margin="9,0,9,0" Text="New library"/>
                </local:MenuButton>

                <local:MenuButton x:Name="menuRemoveLibrary" Margin="0,3,0,4" 
                                  Height="24" Width="Auto">
                    <TextBlock Margin="9,0,9,0" Text="Remove library"/>
                </local:MenuButton>

            </StackPanel>

            <local:MenuDropButton Height="24" Width="45" Margin="0,3,117,4"
                                  HorizontalAlignment="Right"
                                  Click="CycleModeClick">
                <Image x:Name="imageBrowserMode"
                       Source="Icons/Menu/icon_iconsize_tile.png"
                       Height="16" Width="16" Stretch="Fill"/>
            </local:MenuDropButton>

            <local:MenuButton Height="24" Width="28" Margin="0,3,81,4"
                              HorizontalAlignment="Right"
                              Click="ConfigClick">
                <Image Source="./Icons/Menu/icon_config.png" 
                       Height="16" Width="16" Stretch="Fill"/>
            </local:MenuButton>

            <local:MenuButton Height="24" Width="28" Margin="0,3,45,4"
                              HorizontalAlignment="Right"
                              Click="HelpClick">
                <Image Source="./Icons/Menu/icon_help.png"
                       Height="16" Width="16" Stretch="Fill"/>
            </local:MenuButton>

            <local:MenuButton Height="24" Width="28" Margin="0,3,9,4"
                              HorizontalAlignment="Right"
                              Click="DonateClick">
                <Image Source="./Icons/Menu/icon_donate.png"
                       Height="16" Width="16" Stretch="Fill"/>
            </local:MenuButton>
            
            <!-- Drive operations -->

            <local:MenuButton x:Name="menuFormat" Margin="0,3,170,4"
                                  Height="24" Width="Auto"
                                  HorizontalAlignment="Right">
                <TextBlock Margin="9,0,9,0" Text="Format"/>
            </local:MenuButton>

            <local:MenuToggleButton x:Name="menuFatWbfs" Margin="0,3,246,4"
                                    Height="24" Width="Auto"
                                    HorizontalAlignment="Right">
                <TextBlock Margin="9,0,9,0" Text="Game partition"/>
            </local:MenuToggleButton>

        </Grid>

        <!-- Main -->

        <Grid Margin="0,66,0,0">

            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="53" />
            </Grid.RowDefinitions>

            <Grid Background="#fcfcfc" Grid.Row="0">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <!-- Column 0 - Quick links -->
                
                <ScrollViewer Grid.Column="0" Margin="0,0,0,0"
                              HorizontalScrollBarVisibility="Disabled"
                              VerticalScrollBarVisibility="Auto" >

                    <TreeView x:Name="quickLinksPanel"
                              Margin="-1,0,-2,0" BorderBrush="{x:Null}" 
                              MouseLeftButtonUp="LinkClicked">
                        
                        <local:QuickLink x:Name="quickFavorites" Level="0" Text="Favorites"
                                         Icon="./Icons/Links/icon_fav.png" Margin="0,7,0,0"
                                         Link="%favorites%" IsExpanded="True">

                            <local:QuickLink x:Name="quickDesktop" Level="10" Text="Desktop"
                                         Icon="./Icons/Links/icon_desktop.png" Link="%desktop%"/>

                            <local:QuickLink x:Name="quickDocuments" Level="10" Text="Documents"
                                    Icon="./Icons/Links/icon_docs.png" Link="%documents%"/>
                            
                            <local:QuickLink x:Name="quickRecent" Level="10" Text="Recent Places"
                                        Icon="./Icons/Links/icon_recent.png" Link="%recent%"/>
                            
                            <local:QuickLink x:Name="quickDownloads" Level="10" Text="Downloads"
                                    Icon="./Icons/Links/icon_downl.png" Link="%downloads%"/>

                        </local:QuickLink>
                        
                        <local:QuickLink x:Name="quickLibraries" Level="0" Text="Libraries"
                                         Icon="./Icons/Links/icon_libs.png" Margin="0,21,0,0"
                                         Link="%libraries%" IsExpanded="True"/>

                        <local:QuickLink x:Name="quickComputer" Level="0" Text="Computer"
                                         Icon="./Icons/Links/icon_comp.png" Margin="0,21,0,0"
                                         Link="%computer%" IsExpanded="True"/>

                    </TreeView>
                    
                </ScrollViewer>

                <!-- Column 1 - Separator -->

                <GridSplitter Grid.Column="1" Background="Transparent"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Stretch"
                          Width="3" />

                <Line Stroke="#ffd6e5f5" Grid.Column="1" X1="1" X2="1" Y1="0" Y2="1" Stretch="Fill" IsHitTestVisible="False"/>

                <!-- Column 2 - Fileview -->

                <ListView Name="fileBrowser" Grid.Column="2" Margin="0"
                          ItemContainerStyle="{DynamicResource tileListViewItemStyle}"
                          ItemsSource="{Binding Source={StaticResource collectionViewSource}}"
                          View="{StaticResource tileModeView}"
                          BorderBrush="Transparent"
                          BorderThickness="0"
                          MouseDoubleClick="FileBrowserDoubleClick"
                          MouseUp="FileBrowserClick">
                    
                    <ListView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.ContainerStyle>
                                <Style TargetType="{x:Type GroupItem}">
                                    <Setter Property="Margin" Value="10,0,-10,0"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                                <Expander IsExpanded="True" BorderThickness="0"
                                                          Style="{StaticResource groupExpanderStyle}">
                                                    <Expander.Header>
                                                        <DockPanel>
                                                            <TextBlock Margin="5,0,0,0" FontSize="16"
                                                                       Foreground="#1e3287">
                                                                <Run Text="{Binding Path=Name, Mode=OneWay}"/>
                                                                <Run Text="("/><Run Text="{Binding Path=ItemCount, Mode=OneWay}"/><Run Text=")"/>
                                                            </TextBlock>
                                                        </DockPanel>
                                                    </Expander.Header>
                                                    <Expander.Content>
                                                        <ItemsPresenter />
                                                    </Expander.Content>
                                                </Expander>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </GroupStyle.ContainerStyle>
                        </GroupStyle>
                    </ListView.GroupStyle>
                    
                    <ListView.ContextMenu>
                        <ContextMenu>
                            
                            <MenuItem Margin="0,-1,0,-1" FontWeight="Bold" 
                                      Header="Open"
                                      Command="EditingCommands.EnterParagraphBreak"/>

                            <Separator Margin="0,-1,0,-1"/>

                            <MenuItem Margin="0,-1,0,-1"
                                      Header="Send to"/>

                            <Separator Margin="0,-1,0,-1"/>

                            <MenuItem Margin="0,-1,0,-1"
                                      Header="Cut"
                                      Command="ApplicationCommands.Cut"/>

                            <MenuItem Margin="0,-1,0,-1"
                                      Header="Copy"
                                      Command="ApplicationCommands.Copy"/>

                            <MenuItem Margin="0,-1,0,-1"
                                      Header="Paste"
                                      Command="ApplicationCommands.Paste"/>

                            <MenuItem x:Name="pasteAsMenu" 
                                      Margin="0,-1,0,-1" 
                                      Header="Paste as"/>

                            <Separator Margin="0,-1,0,-1"/>

                            <MenuItem Margin="0,-1,0,-1"
                                      Header="Delete"
                                      Command="EditingCommands.Delete"/>

                            <MenuItem Margin="0,-1,0,-1"
                                      Header="Rename"
                                      Command="EditingCommands.CorrectSpellingError"/>
                            
                        </ContextMenu>
                    </ListView.ContextMenu>
                </ListView>

            </Grid>
            
            <!-- Row 1 - Separator -->

            <GridSplitter Grid.Row="1"
                          VerticalAlignment="Center"
                          HorizontalAlignment="Stretch"
                          Height="5">
                <GridSplitter.Background>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Offset="0" Color="#ccd9ea" />
                        <GradientStop Offset="1" Color="#f0f4fa" />
                    </LinearGradientBrush>
                </GridSplitter.Background>
            </GridSplitter>

            <!-- Row 2 - File info -->

            <Grid Grid.Row="2" Background="#f1f5fb">

            </Grid>

        </Grid>
        
    </Grid>
</Window>
